package hot;

import java.util.Stack;

public class qisanjiu {
    public static int[] dailyTemperatures(int[] nums) {
        Stack<Integer> stack=new Stack<>();
        int[] array=new int[nums.length];
        for(int i=0;i<nums.length;i++){
            while(!stack.isEmpty()&&nums[i]>nums[stack.peek()]){
                int m=stack.pop();
                array[m]=i-m;
            }
            stack.push(i);
        }
        return array;
    }

    public static void main(String[] args) {
        int[] nums={73,74,75,71,69,72,76,73};
        int[] ints = dailyTemperatures(nums);
        for(int x:ints){
            System.out.print(x+" ");
        }


    }
}
